home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 35.5 KB | 963 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
- {UDialog.p}
- {Copyright © 1988-1990 by Apple Computer Inc. All rights reserved.}
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := FALSE}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT UDialog;
-
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED __UDialog__}
- {$SETC __UDialog__ := FALSE}
- {$ENDC}
-
- {$IFC NOT __UDialog__}
- {$SETC __UDialog__ := TRUE}
-
- { • Auto-Include the requirements for this unit's interface. }
- {$SETC UDialogIncludes := UsingIncludes}
- {$SETC UsingIncludes := TRUE}
- {$I+}
- {$IFC UNDEFINED __UMacApp__} {$I UMacApp.p} {$ENDC}
- {$IFC UNDEFINED __UTEView__} {$I UTEView.p} {$ENDC}
- {$SETC UsingIncludes := UDialogIncludes}
-
- CONST
- kPreferColor = TRUE; { argument to IIcon }
- kControlOn = TRUE; { argument to ICheckBox and IRadio }
-
- { Constants for TDialogView.Dismiss }
- kFlash = TRUE; { Constants for TDialogView.Dismiss. }
- kDontFlash = FALSE; { Constants for TDialogView.Dismiss. }
-
- kFrame = [adnLineTop, adnLineLeft, adnLineBottom, adnLineRight]; { Constant
- defining that a view be completely framed. }
-
- kMaxTEWidth = $2B0; { Maximum width for TEditText autoscroll }
-
- phInvalidValue = 300; { Alert used when an invalid value is
- entered }
-
- kInvalidValueReasons = 300; { String list used for invalid value alert }
- kErrorHandled = - 1; { Don't post an alert, the user handled it }
- kValidValue = 0; { Not looked up in the string list. }
- kInvalidValue = 1;
- kValueTooSmall = 2;
- kValueTooLarge = 3;
- kNonNumericCharacters = 4;
- kTooManyCharacters = 5;
- kNoOfDefaultReasons = 5;
-
- TYPE
-
- DialogViewTemplate = RECORD
- defaultItem: IDType;
- cancelItem: IDType;
- END;
- DialogViewTemplatePtr = ^DialogViewTemplate;
-
- {$IFC qHasForward}
- TEditText = OBJECT; FORWARD;
- TDialogTEView = OBJECT; FORWARD;
- {$EndC}
-
- TDialogView = OBJECT (TView) { Mimics normal toolbox dialogs providing
- behavior for handling default buttons,
- param text, currently selected edit text
- and other behavior typically associated
- with dialogs. }
- fDefaultItem: IDType; { The identifier of the default item }
- fCancelItem: IDType; { The identifier of item that cancels dialog
- }
- fParamTxt: TAssociation; { the list of TEntrys for replacement }
- fCurrentEditText: TEditText; { Currently selected edit text item }
- fTEView: TDialogTEView; { Used for editing in EditText views }
- fDismissed: BOOLEAN; { Has the dialog been dismissed? }
- fDismisser: IDType; { ID of view that caused dismissal }
-
- PROCEDURE TDialogView.IDialogView(itsDocument: TDocument;
- itsSuperView: TView;
- itsLocation: VPoint;
- itsSize: VPoint;
- itsHSizeDet: SizeDeterminer;
- itsVSizeDet: SizeDeterminer;
- itsDefItemID: IDType;
- itsCancelItemID: IDType);
- { Initialization method for TDialogView. }
-
- PROCEDURE TDialogView.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { For initializing a dialog view from a resource template. }
-
- PROCEDURE TDialogView.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a dialog view out to a resource. }
-
- PROCEDURE TDialogView.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a dialog view to a resource, works in conjunction with tbe
- previous method. }
-
- PROCEDURE TDialogView.Free; OVERRIDE;
- { Frees fParamTxt then removes the sub view fTEView before calling inherited Free. }
-
- FUNCTION TDialogView.CanDismiss(dismissing: IDType): BOOLEAN;
- { Used to check whether the dialog view can be dismissed or not by checking if the
- view is enabled, then check if the currently selected edit text is valid. }
-
- PROCEDURE TDialogView.CantDeselect(theEditText: TEditText;
- reason: LONGINT);
-
- PROCEDURE TDialogView.Close; OVERRIDE;
- { Called to close a dialog view. }
-
- PROCEDURE TDialogView.DismissDialog(dismisser: IDType);
- { The method responsible for actually dismissing a dialog. }
-
- FUNCTION TDialogView.DoCommandKey(ch: CHAR;
- VAR info: EventInfo): TCommand; OVERRIDE;
- { Called when a keyDown event is received and the command key is down. }
-
- FUNCTION TDialogView.DoKeyCommand(ch: CHAR;
- aKeyCode: INTEGER;
- VAR info: EventInfo): TCommand; OVERRIDE;
- { This method handles all key presses other than a command key press, which is
- handled by the previous method. }
-
- PROCEDURE TDialogView.DoOpen;
- { If when opening the dialog the current target is an edit text field of the dialog,
- then select it. }
-
- FUNCTION TDialogView.DeselectCurrentEditText: BOOLEAN;
- { Deselects the current edit text, this is called when tabbing between edit text
- fields. }
-
- PROCEDURE TDialogView.DoSelectEditText(theEditText: TEditText;
- selectChars: BOOLEAN);
- { Selects theEditText, is selectChars then all the characters are selected otherwise
- the insertion point is merely placed at the start of the field. }
-
- PROCEDURE TDialogView.EachEditText(PROCEDURE
- DoToEditText(theEditText: TEditText));
- { Iterates over all the edit text items in the dialog calling DoToEditText for
- each item. }
-
- FUNCTION TDialogView.GetDialogView: TView; OVERRIDE;
- { Returns a reference to the dialog view. }
-
- PROCEDURE TDialogView.Tab(tabBackward: BOOLEAN);
- { Handles the tabbing between edit text fields. }
-
- PROCEDURE TDialogView.DoChoice(origView: TView;
- itsChoice: INTEGER); OVERRIDE;
- { If the default or cancel key are pressed then dismisses the dialog, otherwise
- passes the message along the chain. If the hit was an edit text item then deselects
- the item. Otherwise if the hit is on some other control and it dismisses the dialog
- then dismiss it. }
-
- FUNCTION TDialogView.MakeTEView: TDialogTEView;
- { Creates the floating TEView used with edit text fields. }
-
- PROCEDURE TDialogView.Open; OVERRIDE;
- { Called to open a dialog. }
-
- PROCEDURE TDialogView.ParamTxt(keyStr, valueStr: Str255);
- { Used to create paramTxt items for the dialog. Builds an association with keyStr
- and valueStr. All instance of keyStr in the dialog will be replaced with valueStr
- when the dialog is displayed. }
-
- FUNCTION TDialogView.PoseModally: IDType;
- { Displays the dialog in a modal fashion waiting for a response, which is returned
- as the IDType of the button hit that causes the dialog to be dismissed. }
-
- PROCEDURE TDialogView.ReplaceText(VAR theText: Str255);
- { If there are any param text items in the theText passed to this method then they
- are replaced with the appropriate values. }
-
- PROCEDURE TDialogView.SelectEditText(itsIdentifier: IDType;
- selectChars: BOOLEAN);
- { If itsIdentifier can be found then the field is selected, selectChars if true means
- that all the text will be selected as opposed to the insertion point merely being
- placed in the field. }
-
- PROCEDURE TDialogView.SurveyEditText(VAR first, last, next, previous: TEditText);
- { Iterates over the edit text items in the view finding the First, Last, Next and
- Previous items. }
-
- PROCEDURE TDialogView.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- ButtonTemplate = RECORD
- itsLabel: Str255; { Actually, variable length }
- END;
- ButtonTemplatePtr = ^ButtonTemplate;
-
- TButton = OBJECT (TCtlMgr) { Mimics a typical toolbox button as used in
- a dialog. }
- PROCEDURE TButton.IButton(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsLabel: Str255);
- { Initializes the button setting the fDefChoice field to mButtonHit. }
-
- PROCEDURE TButton.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view from a resource template. }
-
- PROCEDURE TButton.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write this object out as a view resource. }
-
- PROCEDURE TButton.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TButton.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- CheckBoxTemplate = RECORD
- isOn: BOOLEAN;
- itsLabel: Str255; { Actually, variable length }
- END;
- CheckBoxTemplatePtr = ^CheckBoxTemplate;
-
- TCheckBox = OBJECT (TCtlMgr) { Provides the functionality of a toolbox
- checkbox. }
- PROCEDURE TCheckBox.ICheckBox(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsLabel: Str255;
- isTurnedOn: BOOLEAN);
- { Initialize the checkbox setting fDefChoice to mCheckBoxHit. }
-
- PROCEDURE TCheckBox.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view from a resource template. }
-
- PROCEDURE TCheckBox.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write this object out as a view resource. }
-
- PROCEDURE TCheckBox.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TCheckBox.DoChoice(origView: TView;
- itsChoice: INTEGER); OVERRIDE;
- { If the hit is mCheckBoxHit then toggle the checkbox. }
-
- FUNCTION TCheckBox.IsOn: BOOLEAN;
- { Is the checkbox currently checked. }
-
- PROCEDURE TCheckBox.SetState(state, redraw: BOOLEAN);
- { Sets the state of the checkbox to state and if redraw is TRUE redraws it. }
-
- PROCEDURE TCheckBox.Toggle(redraw: BOOLEAN);
- { Toggles the state of the checkbox redraw it if redraw is TRUE. }
-
- PROCEDURE TCheckBox.ToggleIf(matchState, redraw: BOOLEAN);
- { Toggles the state of the checkbox if matchState is TRUE redrawing if redraw is
- TRUE. }
-
- PROCEDURE TCheckBox.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- RadioTemplate = RECORD
- isOn: BOOLEAN;
- itsLabel: Str255; { Actually, variable length }
- END;
- RadioTemplatePtr = ^RadioTemplate;
-
- TRadio = OBJECT (TCtlMgr) { Provides the functionality of a toolbox
- radio button. }
- PROCEDURE TRadio.IRadio(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsLabel: Str255;
- isTurnedOn: BOOLEAN);
- { Initalize the radio button procedurally. }
-
- PROCEDURE TRadio.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view from a resource template. }
-
- PROCEDURE TRadio.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TRadio.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TRadio.DoChoice(origView: TView;
- itsChoice: INTEGER); OVERRIDE;
- { If the hit is mRadioHit then toggle the radio button. }
-
- FUNCTION TRadio.IsOn: BOOLEAN;
- { Is the radio button currently on. }
-
- PROCEDURE TRadio.SetState(state, redraw: BOOLEAN);
- { Sets the state of the radio button to state, redrawing if redraw is TRUE. }
-
- PROCEDURE TRadio.Toggle(redraw: BOOLEAN);
- { Toggles the state of the radio button, redrawing if redraw is TRUE. }
-
- PROCEDURE TRadio.ToggleIf(matchState, redraw: BOOLEAN);
- { Only toggles the state of the radio button if matchState is TRUE, redrawing if
- redraw is TRUE. }
-
- PROCEDURE TRadio.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- ClusterTemplate = RECORD
- itsLabel: Str255; { Actually, variable length }
- END;
- ClusterTemplatePtr = ^ClusterTemplate;
-
- TCluster = OBJECT (TControl) { Provides a mechanism whereby radio buttons
- can be grouped in clusters, such that when
- one of the buttons is selected the others
- are all deselected. Also can be utilized
- for providing labelled adornments around
- groups of dialog items. }
- fRsrcID: INTEGER; { resource ID of the cluster's label }
- fIndex: INTEGER; { currently selected item }
- fDataHandle: StringHandle; { the cluster's label }
-
- PROCEDURE TCluster.ICluster(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsRsrcID, itsIndex: INTEGER);
- { Initialize the cluster procedurally. }
-
- PROCEDURE TCluster.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TCluster.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TCluster.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TCluster.Free; OVERRIDE;
- { Release the label and call inherited free. }
-
- PROCEDURE TCluster.Draw(area: Rect); OVERRIDE;
- { Frame the cluster if there is a label, then draw the label. }
-
- PROCEDURE TCluster.DoChoice(origView: TView;
- itsChoice: INTEGER); OVERRIDE;
- { Responsible for reset the radio buttons so that the last selected one is the only
- one selected. }
-
- PROCEDURE TCluster.GetLabel(VAR theLabel: Str255);
- { Returns in theLable the text in the clusters label. }
-
- PROCEDURE TCluster.ReleaseLabel;
- { Releases fDataHandle which is a string handle containing the text for the label. }
-
- FUNCTION TCluster.ReportCurrent: IDType;
- { Returns the IDType of the currently selected item. }
-
- PROCEDURE TCluster.SetLabel(theLabel: Str255;
- redraw: BOOLEAN);
- { Sets the clusters label to be theLabel, redrawing if redraw is TRUE. }
-
- PROCEDURE TCluster.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- IconTemplate = RECORD
- preferColor: BOOLEAN;
- rsrcID: INTEGER;
- END;
- IconTemplatePtr = ^IconTemplate;
-
- TIcon = OBJECT (TControl) { Provides an icon that can behave as a
- button. }
- fPreferColor: BOOLEAN;
- fRsrcID: INTEGER;
- fDataHandle: Handle;
-
- PROCEDURE TIcon.IIcon(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsRsrcID: INTEGER;
- preferColor: BOOLEAN);
- { Initialize the view template. }
-
- PROCEDURE TIcon.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TIcon.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TIcon.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TIcon.Free; OVERRIDE;
- { Release the icon then call inherited Free. }
-
- PROCEDURE TIcon.Draw(area: Rect); OVERRIDE;
- { Resonsible for drawing the icon and any required adornments. }
-
- PROCEDURE TIcon.ReleaseIcon;
- { Releases the handle to the icon. }
-
- PROCEDURE TIcon.SetIcon(theIcon: Handle;
- redraw: BOOLEAN);
- { Sets fDataHandle to theIcon, redrawing if redraw is TRUE. }
-
- PROCEDURE TIcon.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- PatternTemplate = RECORD
- preferColor: BOOLEAN;
- rsrcID: INTEGER;
- END;
- PatternTemplatePtr = ^PatternTemplate;
-
- TPattern = OBJECT (TControl) { Provides an object that can display a
- pattern and can also behave as a button if
- required. }
- fPreferColor: BOOLEAN;
- fRsrcID: INTEGER;
- fDataHandle: Handle;
-
- PROCEDURE TPattern.IPattern(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsRsrcID: INTEGER;
- preferColor: BOOLEAN);
- { Initialize the pattern procedurally. }
-
- PROCEDURE TPattern.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TPattern.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TPattern.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TPattern.Free; OVERRIDE;
- { Release the pattern then call inherited Free. }
-
- PROCEDURE TPattern.Draw(area: Rect); OVERRIDE;
- { Responsible for drawing the pattern and any required adornments. }
-
- PROCEDURE TPattern.ReleasePattern;
- { Releases the pattern by disposing fDataHandle. }
-
- PROCEDURE TPattern.SetPattern(thePattern: Handle;
- redraw: BOOLEAN);
- { Sets fDataHandle to thePattern, redrawing if redraw is TRUE. }
-
- PROCEDURE TPattern.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- PictureTemplate = RECORD
- rsrcID: INTEGER;
- END;
- PictureTemplatePtr = ^PictureTemplate;
-
- TPicture = OBJECT (TControl) { Provides an object that can display a PICT
- and if required behave like a button. }
- fRsrcID: INTEGER;
- fDataHandle: PicHandle;
-
- PROCEDURE TPicture.IPicture(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsRsrcID: INTEGER);
- { Initialize the picture procedurally. }
-
- PROCEDURE TPicture.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view from a resource template. }
-
- PROCEDURE TPicture.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TPicture.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TPicture.Free; OVERRIDE;
- { Release the picture then call inherited Free. }
-
- PROCEDURE TPicture.Draw(area: Rect); OVERRIDE;
- { Responsible for drawing the PICT and any required adornments. }
-
- PROCEDURE TPicture.ReleasePicture;
- { Releases the PICT by disposing of fDataHandle. }
-
- PROCEDURE TPicture.SetPicture(thePicture: PicHandle;
- redraw: BOOLEAN);
- { Sets fDataHandle to thePicture, redrawing if redraw is TRUE. }
-
- PROCEDURE TPicture.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- PopupTemplate = RECORD
- rsrcID: INTEGER;
- currentItem: INTEGER;
- itemOffset: INTEGER;
- END;
- PopupTemplatePtr = ^PopupTemplate;
-
- TPopup = OBJECT (TControl) { Provides a popup menu that can have a
- label associated with it. }
- fRsrcID: INTEGER;
- fMenuID: INTEGER;
- fMenuHandle: MenuHandle;
- fCurrentItem: INTEGER;
- fItemOffset: INTEGER;
-
- PROCEDURE TPopup.IPopup(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsRsrcID, itsCurrentItem, itsItemOffset: INTEGER);
- { Initialize the popup procedurally. }
-
- PROCEDURE TPopup.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TPopup.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TPopup.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TPopup.Free; OVERRIDE;
- { Release the popup then calls inherited Free. }
-
- PROCEDURE TPopup.AdjustBotRight;
- { Adjusts the width and height of the popup menu. }
-
- PROCEDURE TPopup.CalcLabelRect(VAR theRect: Rect);
- { Calculates the size of the rect for the label. }
-
- PROCEDURE TPopup.CalcMenuRect(VAR theRect: Rect);
- { Calculates the size of the rect for the menu. }
-
- FUNCTION TPopup.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Responds to a mouse down on the popup menu by highlighting the label and then
- calling PopUpMenuSelect to handle the display of the menu and then sets the current
- item to the one selected. }
-
- PROCEDURE TPopup.Draw(area: Rect); OVERRIDE;
- { Calls DrawPopupBox and DrawLabel to handle the drawing of the popup box and the
- label. }
-
- PROCEDURE TPopup.DrawLabel(area: Rect);
- { Responsible for drawing the label. }
-
- PROCEDURE TPopup.DrawPopupBox(area: Rect);
- { Does the actual drawing of the popup box. }
-
- FUNCTION TPopup.GetCurrentItem: INTEGER;
- { Returns the currently check marked item. }
-
- PROCEDURE TPopup.GetItemText(item: INTEGER;
- VAR theText: Str255);
- { Gets the text for the currently selected item. }
-
- PROCEDURE TPopup.ReleasePopup;
- { Releases the popup by disposing of the menu handle. }
-
- PROCEDURE TPopup.SetCurrentItem(item: INTEGER;
- redraw: BOOLEAN);
- { Sets the currently selected item, redrawing is required. }
-
- PROCEDURE TPopup.SetPopup(theMenu: MenuHandle;
- theRsrcID, currentItem: INTEGER;
- redraw: BOOLEAN);
- { Sets the fields of the popup to contain theMenu, with currentItem selected,
- redrawing if required. }
-
- PROCEDURE TPopup.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- StaticTextTemplate = RECORD
- just: INTEGER;
- data: Str255; { Actually, variable length }
- END;
- StaticTextTemplatePtr = ^StaticTextTemplate;
-
- TStaticText = OBJECT (TControl) { Provides an object that represents a
- toolbox static text item. }
- fRsrcID: INTEGER; { ID of the string list that the string is
- in. }
- fIndex: INTEGER; { Index number for the string from the above
- list. }
- fDataHandle: StringHandle; { A handle to the actual string. }
- fJust: INTEGER; { Jusitification of the text in the field. }
- fAutoWrap: BOOLEAN; { TRUE to word wrap lines at the view boundary
- otherwise lines wrap at Carriage return. }
-
- PROCEDURE TStaticText.IStaticText(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsRsrcID, itsIndex: INTEGER);
- { Initialize the static text field procedurally. }
-
- PROCEDURE TStaticText.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TStaticText.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TStaticText.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TStaticText.Free; OVERRIDE;
- { Releases the text and then calls inherited Free. }
-
- PROCEDURE TStaticText.DoSubstitution(VAR theText: Str255);
- { Calls ReplaceText so that any paramTxt items can be handled if needed. }
-
- PROCEDURE TStaticText.Draw(area: Rect); OVERRIDE;
- { Draws the text by calling ImageText. }
-
- PROCEDURE TStaticText.GetText(VAR theText: Str255);
- { If fDataHandle not NIL then returns the text, otherwise returns the null string. }
-
- PROCEDURE TStaticText.ImageText(text: Ptr;
- length: LONGINT;
- box: Rect;
- just: INTEGER);
- { Draws the text using the toolbox routine TextBox. }
-
- PROCEDURE TStaticText.ChangeWrap(newAutoWrap, redraw: BOOLEAN);
- { Changes auto-wrapping behavior, redrawing if requested }
-
- PROCEDURE TStaticText.ReleaseText;
- { Releases the text by disposing of fDataHandle. }
-
- PROCEDURE TStaticText.SetJustification(theJust: INTEGER;
- redraw: BOOLEAN);
- { Sets the justification of the text to theJust, redrawing if required. }
-
- PROCEDURE TStaticText.SetText(theText: Str255;
- redraw: BOOLEAN);
- { Sets the text to theText, redrawing if required. }
-
- PROCEDURE TStaticText.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- EditTextTemplate = RECORD
- maxChars: INTEGER;
- controlChars: ControlCharSet;
- END;
- EditTextTemplatePtr = ^EditTextTemplate;
-
- TEditText = OBJECT (TStaticText) { Implements an edit text field. }
- fMaxChars: INTEGER;
- fTEView: TDialogTEView;
- fControlChars: ControlCharSet; { Control chars accepted in text }
-
- PROCEDURE TEditText.IEditText(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsMaxChars: INTEGER);
- { Initialize the edit text item procedurally. }
-
- PROCEDURE TEditText.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view from a resource template. }
-
- PROCEDURE TEditText.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TEditText.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- PROCEDURE TEditText.Free; OVERRIDE;
- { Un-installs the floating TEView, sets fTEView to NIL then calls inherited Free. }
-
- FUNCTION TEditText.HandleMouseDown(theMouse: VPoint;
- VAR info: EventInfo;
- VAR hysteresis: Point;
- VAR theCommand: TCommand): BOOLEAN; OVERRIDE;
- { Gets the floating TE installed if necessary and forwards the call to it. }
-
- PROCEDURE TEditText.DoSubstitution(VAR theText: Str255); OVERRIDE;
- { Default is to do nothing. }
-
- PROCEDURE TEditText.Draw(area: Rect); OVERRIDE;
- { If TEView not NIL then calls TEView.Draw before performing any required adornments,
- else calls inherited Draw. }
-
- PROCEDURE TEditText.GetText(VAR theText: Str255); OVERRIDE;
- { If TEView not NIL then returns the extracted text, otherwise calls inherited
- GetText. }
-
- PROCEDURE TEditText.ImageText(text: Ptr;
- length: LONGINT;
- box: Rect;
- just: INTEGER); OVERRIDE;
- { Sets up the text to the parameters passed. Text is drawn in a'box' , the text is
- 'length' long. }
-
- PROCEDURE TEditText.InstallSelection(wasActive, beActive: BOOLEAN); OVERRIDE;
- { If TEView not NIL then calls TEView.InstallSelection. }
-
- PROCEDURE TEditText.RestartEdit(restartText: Str255);
- { This method resets the text of the view, as well as selecting the text. We go to
- some extra trouble to ensure that this method doesn't do any drawing, defering to
- window update time. The reasoning is that this method usually gets called right
- after displaying an alert. The alert may have obscured this view, thus including it
- in the window's update region. If we drew in this method we would get flashing as
- this view would get redraw at update time. Unfortunately TextEdit isn't very
- cooperative so we set the clipping to an empty rect to ensure that TEActivate's
- drawing isn't seen. }
-
- PROCEDURE TEditText.ChangeWrap(newAutoWrap, redraw: BOOLEAN); OVERRIDE;
- { Changes auto-wrapping behavior, redrawing if requested. Forwards into
- the floating TE if necessary. }
-
- PROCEDURE TEditText.SetJustification(theJust: INTEGER;
- redraw: BOOLEAN); OVERRIDE;
- { Sets the justification of the text to theJust, redrawing is required. }
-
- PROCEDURE TEditText.SetSelection(selStart, selEnd: INTEGER;
- redraw: BOOLEAN);
- { Sets the selection in the field starting at selStart and ending at selEnd,
- redrawing if required. }
-
- PROCEDURE TEditText.SetText(theText: Str255;
- redraw: BOOLEAN); OVERRIDE;
- { Sets the displayed text to theText, redrawing if required. }
-
- PROCEDURE TEditText.StartEdit(selectChars: BOOLEAN;
- theTEView: TDialogTEView);
- { Install the selection, revealing the selection if required. }
-
- PROCEDURE TEditText.StopEdit;
- { Extracts the string from the TEView, then clears out the TEView before calling
- SELF.SetText. }
-
- FUNCTION TEditText.Validate: LONGINT; OVERRIDE;
- { By default just returns TRUE. }
-
- PROCEDURE TEditText.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- NumberTextTemplate = RECORD
- value: LONGINT;
- minimum: LONGINT;
- maximum: LONGINT;
- END;
- NumberTextTemplatePtr = ^NumberTextTemplate;
-
- TNumberText = OBJECT (TEditText) { This subclass of TEditText that allows the
- handling of integer numbers. Range
- checking will be performed on the numbers
- entered to see if they are in the range
- fMinimum to fMaximum. }
- fMinimum: LONGINT;
- fMaximum: LONGINT;
-
- PROCEDURE TNumberText.INumberText(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsValue, itsMinimum, itsMaximum: LONGINT);
- { Initialize the number text item procedurally. }
-
- PROCEDURE TNumberText.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the view template. }
-
- PROCEDURE TNumberText.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Write the object out as a view resource. }
-
- PROCEDURE TNumberText.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { Set up the type and signature of this object and call WRes. }
-
- FUNCTION TNumberText.GetValue: LONGINT;
- { Returns the current value by getting the string and converting it to a number. }
-
- PROCEDURE TNumberText.SetValue(newValue: LONGINT;
- redraw: BOOLEAN);
- { Sets the current value by converting the number to a string and then calling
- SetText. }
-
- FUNCTION TNumberText.Validate: LONGINT; OVERRIDE;
- { Does a range check on the number and if it is out of range returns the appropriate
- error code. }
-
- PROCEDURE TNumberText.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- TDialogTEView = OBJECT (TTEView) { Provides a floating TEView that is placed
- over edit & number text fields when
- entering text. }
- fEditText: TEditText; { The edit text field to which the floating
- TEView is currently tied. }
-
- fScroller: TScroller; { The scroller that I am in for mouseability. }
-
- PROCEDURE TDialogTEView.IDialogTEView(itsDocument: TDocument; { OK to be NIL, if view will
- belong to a documentless window
- }
- itsSuperView: TView; { The view in which this view is
- contained }
- itsLocation: VPoint; { Location in its superview }
- itsSize: VPoint; { Size of view }
- itsHDeterminer: SizeDeterminer; { How to width of the view
- is to be determined }
- itsVDeterminer: SizeDeterminer; { How the height of the
- view is to be determined
- }
- itsInset: Rect; { Amount to inset text }
- itsTextStyle: TextStyle; { Initial text style }
- itsJustification: INTEGER; { Its justification }
- itsStyleType: BOOLEAN; { Whether or not record is styled }
- itsAutoWrap: BOOLEAN { FALSE if newline occurs at CR only
- }
- );
- { For Initialization of procedurally created TEView. }
-
- PROCEDURE TDialogTEView.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize a TTEView via a 'view' resource. }
-
- PROCEDURE TDialogTEView.Free; OVERRIDE;
- { Free associated components and then free self. }
-
- PROCEDURE TDialogTEView.InstallEditText(theEditText: TEditText;
- selectChars: BOOLEAN);
- { Installs the EditText adding SELF as a subview to EditText, then gets the text
- from the EditText item and installs it in SELF. }
-
- PROCEDURE TDialogTEView.ComputeSize(VAR newSize: VPoint); OVERRIDE;
- { accounts for case in which horizontal determiner is sizeVariable should be added
- to TTEView !!! }
-
- PROCEDURE TDialogTEView.InstallSelection(wasActive, beActive: BOOLEAN); OVERRIDE;
- { If deactivating then invalidate rect before calling inherited InstallSelection. }
-
- PROCEDURE TDialogTEView.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- FUNCTION TDialogTEView.MakeScroller: TScroller;
- { Creates the floating scroller that goes with the TE. }
-
- END;
-
- PROCEDURE InitUDialog;
- { This routine must be called if UDialog is used so that all the necessary initialization can
- be performed. Sets the global flag 'gUDialogInitialized' after the initalization is
- performed. }
-
- PROCEDURE GetMenuColors(popupRect: Rect;
- menuID, itemNum: INTEGER;
- VAR fColor, bColor: RGBColor);
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-